package com.zpark.controller;

import com.zpark.pojo.User;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.client.RestTemplate;

/**
 * @PackageName: com.zpark.controller
 * @ClassName: UserConsumerController
 * @Description:
 * @author: RZS
 * @date: 2024/4/16  14:47
 */
@RestController
@RequestMapping("/user-consumer")
public class UserConsumerController {

    // 自动注入restTemplate
    @Autowired
    private RestTemplate restTemplate;

    // 定义远程访问路径
    // 使用eureka服务当中注册的服务名字访问
    private String url = "http://service-user/user-service/";

    @GetMapping("/get")
    public User getUser(){
        return restTemplate.getForObject(url + "get", User.class);
    }
}
